package com.yicoollxing.common;

import java.util.Set;

import javax.management.RuntimeErrorException;

import com.google.common.collect.Sets;

public class Const {
	public static final String CURRENT_USER = "current_user";
	public static final String USERNAME = "username";
	public static final String EMAIL = "email";

	public interface Role {
		int ROLE_CUSTOMER = 0;
		int ROLE_ADMIN = 1;
	}

	public interface Cart {
		int UNCHECKED = 0;
		int CHECKED = 1;
		String LIMIT_NUM_SUCCESS = "LIMIT_NUM_SUCCESS";
		String LIMIT_NUM_FAILE = "LIMIT_NUM_FAILE";
	}
	
	public interface ProductListOrderBy{
		Set<String> PRICE_ASC_DESC=Sets.newHashSet("price_asc","price_desc");
	}

	public enum ProductStatusEnum {

		ON_SALE(1, "在线");

		private int code;
		private String desc;
		
		ProductStatusEnum(int code,String desc){
			this.code=code;
			this.desc=desc;
		}

		public int getCode() {
			return code;
		}

		public String getDesc() {
			return desc;
		}

	}
	
	public enum OrderStatusEnum {

		CANCLED(0, "取消"),
		NO_PAY(10, "未支付"),
		PAID(20, "已付款"),
		SHIPPED(40, "已发货"),
		ORDER_SUCCESS(50, "订单完成"),
		ORDER_CLOSE(60, "订单关闭");

		private int code;
		private String desc;
		
		OrderStatusEnum(int code,String desc){
			this.code=code;
			this.desc=desc;
		}
		

		public int getCode() {
			return code;
		}

		public String getDesc() {
			return desc;
		}

		public static OrderStatusEnum codeOf(int code){
			 for(OrderStatusEnum  orderStatus:values()){
				 if(code==orderStatus.getCode()){
					 return orderStatus;
				 }
			 }
			
			throw new RuntimeException("没有找到对应的枚举");
		}
	}
	
	public interface AliyCallBack{
		String TRADE_STATUS_WAIT_BUYER_PAY="WAIT_BUYER_PAY";  //等待买家支付
		String TRADE_STATUS_RADE_SUCCESS="TRADE_SUCCESS";  //支付成功
		String TRADE_STATUS_TRADE_CLOSED="TRADE_CLOSED";   //未付款交易超时关闭，或支付完成后全额退款
		String TRADE_STATUS_TRADE_FINISHED="TRADE_FINISHED"; //交易结束，不可退款
		
		String RESPONSE_SUCCESS="SUCESS";
		String RESPONSE_FAILED="FAILED";
	}
	
	public enum PayPlatformEnum {

		ALIPAY(1, "支付宝");
	

		private int code;
		private String desc;
		
		PayPlatformEnum(int code,String desc){
			this.code=code;
			this.desc=desc;
		}
		

		public int getCode() {
			return code;
		}

		public String getDesc() {
			return desc;
		}

	}
	
	public enum PayTypeEnum {

		ONLINE_PAY(1, "线上支付");
		

		private int code;
		private String desc;
		
		PayTypeEnum(int code,String desc){
			this.code=code;
			this.desc=desc;
		}
		

		public int getCode() {
			return code;
		}
		
		
		public String getDesc() {
			return desc;
		}

        
		public static PayTypeEnum codeOf(int code){
			 for(PayTypeEnum  payType:values()){
				 if(code==payType.getCode()){
					 return payType;
				 }
			 }
			
			throw new RuntimeException("没有找到对应的枚举");
		}
	}
}
